package com.rivulet.doj_backend.controller.admin;


import com.rivulet.doj_backend.pojo.UserInformation;
import com.rivulet.doj_backend.service.UserInformationService;
import com.rivulet.doj_backend.tools.ResultFul;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(origins = {"http://localhost:8080", "null"})
@RestController
@RequestMapping(value = ("/doj"))
public class UserInformationController {
    @Autowired
    UserInformationService userInformationService;

    @RequestMapping(value = ("/user/{user_id}/information_changes"),method = RequestMethod.POST)
    public ResultFul updateInformation(@PathVariable("user_id") Integer user_id,@RequestBody UserInformation userInformation) {
        userInformation.setId(user_id);
        System.out.println(userInformation.toString());
        return userInformationService.updateInformation(userInformation);
    }
    @RequestMapping(value = ("/user/{user_id}"),method = RequestMethod.POST)
    public ResultFul selectinformation(@PathVariable("user_id") Integer user_id){
        System.out.println(user_id);
        return userInformationService.selectUserInformation(user_id);
    }
}
